<#include "../common/layout/__mainlayout.html">
<#include "../common/__pagination.html">

    <!--设置面包屑-->
    <#assign pageBreadCrumbs>
        <li class="active"><a href="#">客户端管理</a></li>
        <li class="active"><a href="#">消息管理</a></li>
    </#assign>
    <#assign pageCss>
        <!-- page specific plugin styles -->
        <link rel="stylesheet" href="${ctx}/static/admin/assets/css/jquery-ui.custom.css"/>
        <link rel="stylesheet" href="${ctx}/static/admin/assets/css/chosen.css"/>
        <link rel="stylesheet" href="${ctx}/static/admin/assets/css/datepicker.css"/>
        <link rel="stylesheet" href="${ctx}/static/admin/assets/css/daterangepicker.css"/>
    </#assign>

    <#assign pageJavascript>
        <script type="text/javascript">
            $(document).ready(function () {

                $("#msgObj").val(${query.msgObj!});


                $('[data-rel=tooltip]').tooltip();

                if (!ace.vars['touch']) {
                    $('.chosen-select').chosen({allow_single_deselect: true});
                }


                //初始化范围选择器
                $('input[name=beginDateRange]').daterangepicker({
                    'applyClass' : 'btn-sm btn-success',
                    'cancelClass' : 'btn-sm btn-default',
                    locale: {
                        applyLabel: '确定',
                        cancelLabel: '取消',
                    }
                })

                // 清除远程modal数据
                $("#editModal").on("hidden.bs.modal", function () {
                    $(this).removeData("bs.modal");
                });

                // 删除按钮
                $("a.delete").on(ace.click_event, function (e) {
                    var currentA = this;
                    e.preventDefault();
//                bootbox.setDefaults({locale:"zh_CN"});
                    bootbox.confirm({
                                message: "确定删除该用户?",
                                buttons: {
                                    confirm: {
                                        label: "确定",
                                        className: "btn-primary btn-sm"
                                    },
                                    cancel: {
                                        label: "取消",
                                        className: "btn-sm"
                                    }
                                },
                                callback: function (result) {
                                    if (result) {
                                        $.get($(currentA).attr("href"), { },function(data){
                                            if(data){
                                                window.location.href=window.location.href;
                                            }
                                        });
                                    }
                                }
                            }
                    );
                });
            });
        </script>
    </#assign>

    <@mainlayout pageBreadCrumbs=pageBreadCrumbs pageCss=pageCss pageJavascript=pageJavascript
    currentMenu="ClientFlag-notifyPushFlag">
    <div class="row">
        <div class="col-xs-12">
            <form id="searchForm" class="form-search form-inline">
                <div class="form-group  col-xs-12" style="padding-top:10px">
                    <label class="col-xs-1 text-right" for="msgObj">消息对象:</label>
                    <select class="col-xs-2"  name="msgObj" id="msgObj" data-placeholder="Choose a State...">
                        <option value="-1">请选择类型</option>
                        <option value="2">软件</option>
                        <option value="3">专题</option>
                        <option value="4">分类</option>
                        <option value="5">外链</option>
                    </select>

                    <label class="col-xs-1 text-right" for="beginDateRange">消息开始时间:</label>
                    <div class="input-medium input-group">
                        <input class="form-control" type="text" class="input-sm input-small"  value="${query.beginDateRange!}" 　 name="beginDateRange" id="beginDateRange"/>
                    </div>
                    <input type="submit" id="searchBtn" class="btn btn-sm btn-primary" value="查询"/>&nbsp;
                    <a href="${ctx}/admin/notify/edit.do" class="btn btn-sm btn-warning"><i class="ace-icon fa fa-plus"></i>添加</a>
                </div>
                <table id="contentTable" class="table table-striped table-bordered table-hover">
                <thead>
                <tr>
                    <th width="40" align="center">消息编号</th>
                    <th width="100" align="left">消息标题</th>
                    <th width="70" align="left">消息对象</th>
                    <th width="70" align="left">软件ID/专题ID/分类ID/外链</th>
                    <th width="40" align="center">操作</th>
                </tr>
                </thead>
                    <hr>
                    <tbody>
                    <#list notifies.listData as notify>
                        <tr>
                            <td>${notify.id!}</td>
                            <td>${notify.msgTitle!}</td>
                            <td>${notify.msgObjShow!}</td>
                            <td>
                                <#if notify.msgObj==2 || notify.msgObj==3 || notify.msgObj==4>
                                    ${notify.resId!}
                                </#if>
                                <#if notify.msgObj==5>
                                    ${notify.linkUrl!}
                                </#if>
                            </td>
                            <td>
                                <div class="hidden-sm hidden-xs action-buttons">
                                    <a class="green tooltip-success edit" href="${ctx}/admin/notify/edit.do?id=${notify.id!}" data-rel="tooltip"  title="编辑" ><span class="label label-success">编辑</span></a>
                                    <a class="red tooltip-error delete" href="${ctx}/admin/notify/delete.do?id=${notify.id!}" data-rel="tooltip" title="删除"> <span class="label label-danger">删除</span></a>
                                </div>
                            </td>
                        </tr>
                    </#list>
                    </tbody>
            </table>
            <@pagination notifies!/>
            </form>
        </div>

    </div>

    <div id="editModal" class="modal fade"  >
        <div class="modal-dialog" style="width:70%">
            <div class="modal-content">
            </div>
        </div>
    </div>
</@mainlayout>